package com.sweet.thread;

/**
 * 多线程下载网图
 */
public class ThreadDownload extends Thread {
    private String url;
    private String name;

    public ThreadDownload(String url, String name) {
        this.url = url;
        this.name = name;
    }

    @Override
    public void run() {
        WebDownloader load = new WebDownloader();
        load.download(url, name);
        System.out.println("下载了文件：" + name);
    }

    public static void main(String[] args) {
        ThreadDownload t1 = new ThreadDownload("https://inews.gtimg.com/newsapp_bt/0/11181809205/1000", "1.jpg");
        ThreadDownload t2 = new ThreadDownload("https://inews.gtimg.com/newsapp_bt/0/11181809206/1000", "2.jpg");
        ThreadDownload t3 = new ThreadDownload("https://inews.gtimg.com/newsapp_bt/0/11181809207/1000", "3.jpg");
        ThreadDownload t4 = new ThreadDownload("https://inews.gtimg.com/newsapp_bt/0/11181809209/1000", "4.jpg");
        ThreadDownload t5 = new ThreadDownload("https://inews.gtimg.com/newsapp_bt/0/11181809527/1000", "5.jpg");

        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
    }
}
